#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int > vec;
typedef pair < int , int > pii;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 42;

ll st[N], pst[N][N], sst[N];
int n, K;

#define AC { puts("ACCEPTED"), exit(0); }
#define WA { puts("REJECTED"), exit(0); }

void dfs(int x, ll stu) {
	if(x == K + 1) { if((stu & (stu + 1)) == 0) return; WA; }
	int l = __builtin_popcountll(st[x] & stu); stu ^= st[x] & stu;
	int r = l + __builtin_popcountll(sst[x] ^ sst[x - 1]);
	rep(i, l, r) dfs(x + 1, stu | pst[x][i]);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif 
	n = in, K = in; if(n == 1) AC; 
	rep(i, 1, K) {
		int l = in; vec p;
		while(l--) p.pb(in - 1);
		sort(p.begin(), p.end());
		rep(j, 0, (int)p.size() - 1) pst[i][j + 1] = pst[i][j] | 1ll << p[j];
		st[i] = pst[i][p.size()]; sst[i] = sst[i - 1] | st[i];
	}
	if(sst[K] + 1 != 1ll << n) WA;
	dfs(1, 0); AC;
}
